package com.allwees.bs.c.module.order.repository;

import com.allwees.bs.c.module.order.entity.OrderReviewItemEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface OrderReviewItemRepository extends JpaRepository<OrderReviewItemEntity, Long> {
	@Query(value = "SELECT e FROM OrderReviewItemEntity e WHERE e.productUuid = :productUuid and e.status=1 and e.isDeleted = 0",
			countQuery = "SELECT COUNT(1) FROM OrderReviewItemEntity WHERE productUuid = :productUuid and status =1 and isDeleted = 0")
	Page<OrderReviewItemEntity> findProductReviews(@Param("productUuid") String productUuid, Pageable pageable);

	List<OrderReviewItemEntity> findAllByUserUuid(String userUuid);

	List<OrderReviewItemEntity> findAllByOrderUuid(String orderUuid);
}
